import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'


let router = createRouter({
  history: createWebHashHistory(), //createWebHashHistory() hash模式；createWebHistory() history模式
  routes: [
    //  路由映射表
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: () => import('../views/home.vue')
    },
    {
      path: '/list',
      component: () => import('../views/list.vue')
    },
    {
      path: '/goods/:id',
      component: () => import('../views/goods.vue')
    },
    { path: '/:pathMatch(.*)*', redirect: '/home' },
  ]
})
router.beforeEach((to, from) => {
  console.log(to)
  // return true // 相当于以前的不走next函数了  不写return 和 return true相当于以前的next() 
})

export default router